/**
 * Copyright (c) 2012, SHX Studio.
 * All rights reserved.
 * rosary226@gmail.com
 * 
 * @author shenqianfeng
 * @date 2012-9-1  
 * @version 1.0   
 */


package com.xxx.sqfengine;

import com.xxx.sqfengine.primitives.SQFGLCube;
import com.xxx.sqfengine.primitives.SQFGLRectangle;
import com.xxx.sqfengine.primitives.SQFGLVertex;
import com.xxx.sqfengine.transform.SQFGLRotateInfo;
import com.xxx.sqfengine.transform.SQFGLScaleInfo;
import com.xxx.sqfengine.transform.SQFGLTranslateInfo;
import com.xxx.sqfengine.util.SQFGLColor4;

public class MainActivity extends SQFGLActivity {
	
	private SQFGLTranslateInfo translateInfo;
	private SQFGLScaleInfo scaleInfo;
	private SQFGLRotateInfo rotateInfo;

	@Override
	public void initScene() {

		super.initScene();
		
		/*
		 * rectangle 
		 */
		
		/*
		SQFGLVertex v0 = new SQFGLVertex(-0.1f,  0.1f, -0.2f, new SQFGLColor4(255, 0, 0, 255)); //0, Top Left
		SQFGLVertex v1 = new SQFGLVertex(-0.1f, -0.1f, -0.2f, new SQFGLColor4(0, 255, 0, 255)); //1, Bottom Left
		SQFGLVertex v2 = new SQFGLVertex(0.1f, -0.1f, -0.2f, new SQFGLColor4(0, 0, 255, 255)); // 2, Bottom Right
		SQFGLVertex v3 = new SQFGLVertex(0.1f,  0.1f, -0.2f, new SQFGLColor4(0, 255, 255, 255)); // 3, Top Right
		SQFGLRectangle rectangle = new SQFGLRectangle(v0, v1, v2, v3);
	
		translateInfo = new SQFGLTranslateInfo(0.01f, 0.0f, 0.0f);
		rectangle.setTranslateInfo(translateInfo);
		
		scaleInfo = new SQFGLScaleInfo(1.0f, 1.0f, 1.0f);
		rectangle.setScaleInfo(scaleInfo);
		
		rotateInfo = new SQFGLRotateInfo(0.0f, true, false, true);
		rectangle.setRotateInfo(rotateInfo);
		
		mScene.addObject(rectangle);
		*/
		
		/*
		 * cube
		 */
		

		float width = 0.2f;
		float height = 0.2f;
		float depth = 0.2f;
		float deltaZ = 2.0f;
		SQFGLVertex backLeftBottom = new SQFGLVertex(-width, -height, -1*depth - deltaZ, new SQFGLColor4(255, 0, 0, 255));
		SQFGLVertex backRightBottom = new SQFGLVertex(width, -height, -1*depth - deltaZ, new SQFGLColor4(255, 255, 0, 255));
		SQFGLVertex backRightTop = new SQFGLVertex(width,  height, -1*depth - deltaZ, new SQFGLColor4(255, 255, 255, 255));
		SQFGLVertex backLeftTop = new SQFGLVertex(-width,  height, -1*depth - deltaZ, new SQFGLColor4(0, 255, 0, 255));
		SQFGLVertex frontLeftBottom = new SQFGLVertex(-width, -height,  depth - deltaZ, new SQFGLColor4(0, 255, 255, 255));
		SQFGLVertex frontRightBottom = new SQFGLVertex(width, -height,  depth - deltaZ, new SQFGLColor4(0, 0, 255, 255));
		SQFGLVertex frontRightTop = new SQFGLVertex(width,  height,  depth - deltaZ, new SQFGLColor4(255, 0, 255, 255));
		SQFGLVertex frontLeftTop = new SQFGLVertex(-width,  height,  depth - deltaZ, new SQFGLColor4(128, 128, 128, 255));
		
		//SQFGLCube cube = new SQFGLCube(0.2f, 0.2f, 0.2f);
		SQFGLCube cube = new SQFGLCube(backLeftBottom, backRightBottom, backRightTop, backLeftTop, 
				frontLeftBottom, frontRightBottom, frontRightTop, frontLeftTop);
		
		translateInfo = new SQFGLTranslateInfo(0.01f, 0.0f, 0.0f);
		cube.setTranslateInfo(translateInfo);
		
		scaleInfo = new SQFGLScaleInfo(1.0f, 1.0f, 1.0f);
		cube.setScaleInfo(scaleInfo);
		
		rotateInfo = new SQFGLRotateInfo(0.0f, true, false, false);
		cube.setRotateInfo(rotateInfo);
		
		mScene.addObject(cube);
	}

	@Override
	public void updateScene() {
		// TODO Auto-generated method stub
		super.updateScene();
		
		// e.g. 1
		//translateInfo.setDeltaX(translateInfo.getDeltaX() + 0.01f);
		//translateInfo.setDeltaZ(translateInfo.getDeltaZ() - 0.1f);
		
		// e.g. 2
		//scaleInfo.setXScaleRatio(scaleInfo.getXScaleRatio() + 0.1f);
		//scaleInfo.setYScaleRatio(scaleInfo.getYScaleRatio() + 0.1f);
		
		// e.g. 3
		rotateInfo.setDegree(rotateInfo.getDegree() +  1.0f);
	}
    /** Called when the activity is first created. */
	

	/*  @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //setContentView(R.layout.main);
    }*/
	
	
}